package xyz.xmh.pattern.behavioral.mementopattern;

/**
 * @author Administrator
 * <p>
 * 被备忘录保存的类
 */
public class Originator {

    private String state;

    public String getState() {
        return state;
    }

    public void setState(String state) {
        this.state = state;
    }

    /**
     * 保存状态
     *
     * @return 返回备忘录类
     */
    public Memento saveState() {
        return new Memento(this.state);
    }

    /**
     * 恢复状态
     *
     * @param memento 备忘录类
     */
    public void restoreState(Memento memento) {
        this.state = memento.getState();
    }
}
